#!/bin/bash
# The version check in this script is used to avoid commit battles
# between different developers that use different astyle versions as
# different versions might have different output (this has happened in
# the past).

# If project management wishes to take a newer astyle version into use
# just change this string to match the start of astyle version string.
ASTYLE_VERSION="Artistic Style Version 3.0.1"
ASTYLE="astyle"

DETECTED_VERSION=`$ASTYLE --version 2>&1`
if [[ "$DETECTED_VERSION" != ${ASTYLE_VERSION}* ]]; then
    echo "You should use: ${ASTYLE_VERSION}";
    echo "Detected: ${DETECTED_VERSION}"
    exit 1;
fi

style="--style=kr --indent=spaces=4 --indent-namespaces --lineend=linux --min-conditional-indent=0"
options="--options=none --pad-header --unpad-paren --suffix=none --convert-tabs --attach-inlines --attach-classes --attach-namespaces"

$ASTYLE $style $options *.cpp
$ASTYLE $style $options *.h
